package com.lcx.plugin.neteaseCloud.music.entity;

import cn.hutool.core.util.StrUtil;

import java.util.Objects;

/**
 * @author daxiong
 * @date 2021/9/17 上午10:19
 */
public class MusicListEntity {
    /**
     * 歌单id
     */
    private String id;
    /**
     * 歌单名称
     */
    private String name;
    /**
     * 层级。0：用户；1：歌单；2：歌曲
     */
    private int level;

    /**
     * 歌曲id
     */
    private String songId;
    /**
     * 歌曲名称
     */
    private String songName;
    /**
     * 专辑名称
     */
    private String albumName;
    /**
     * 歌曲Url
     */
    private String songUrl;
    /**
     * 歌曲封面
     */
    private String songAvatar;
    /**
     * 作者id
     */
    private String authorId;
    /**
     * 作者名称
     */
    private String authorName;

    public MusicListEntity(String id, String name, int level) {
        this.id = id;
        this.name = name;
        this.level = level;
    }

    @Override
    public String toString() {
        if (level == 2) {
            String suffix = StrUtil.isBlank(authorName) ? "" : " --(by " + authorName + ") ";
            return songName + suffix;
        }
        return name;
    }

    public String getSongId() {
        return songId;
    }

    public void setSongId(String songId) {
        this.songId = songId;
    }

    public String getSongName() {
        return songName;
    }

    public void setSongName(String songName) {
        this.songName = songName;
    }

    public String getAuthorId() {
        return authorId;
    }

    public void setAuthorId(String authorId) {
        this.authorId = authorId;
    }

    public String getAuthorName() {
        return authorName;
    }

    public void setAuthorName(String authorName) {
        this.authorName = authorName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public String getSongUrl() {
        return songUrl;
    }

    public void setSongUrl(String songUrl) {
        this.songUrl = songUrl;
    }

    public String getSongAvatar() {
        return songAvatar;
    }

    public void setSongAvatar(String songAvatar) {
        this.songAvatar = songAvatar;
    }

    public String getAlbumName() {
        return albumName;
    }

    public void setAlbumName(String albumName) {
        this.albumName = albumName;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof MusicListEntity) {
            MusicListEntity entity = (MusicListEntity) obj;
            return Objects.equals(this.getSongId(), entity.getSongId())
                    && Objects.equals(this.getId(), entity.getId());
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + (songId == null ? 0 : songId.hashCode());
        result = 31 * result + (id == null ? 0 : id.hashCode());
        return result;
    }

}
